/**
    Copyright (c) 2009 yakiimo02
    Distributed under the New BSD License.
    See included license.txt or http://www.yakiimo3d.com/NewBSDLicense.txt
**/

#include "DXUT.h"
#include "BitonicSortData.h"

#include <cassert>

/**
    Create data used that will sorted using bitonic sort.
*/
void BitonicSortData::Create()
{
    srand( GetTickCount() );
    m_data.resize( NUM_ELEMENTS );
    for ( int nElem=0; nElem<NUM_ELEMENTS; ++nElem ) 
    {
        m_data[ nElem ].n = static_cast< unsigned int >( ( (rand()*1.0f) / RAND_MAX ) * NUM_ELEMENTS );
    }
}

/**
    Check whether data has been sorted in increasing order.
    @param data    [in]    data to check
*/
void CheckSortUp( const BufTypeVector& data )
{
    for( int nElem=1; nElem<NUM_ELEMENTS; ++nElem )
    {
        if( data[ nElem-1 ] > data[ nElem ] ) {
            assert( 0 );
        }
    }
}

/**
    Check whether data has been sorted in decreasing order.
    @param data    [in]    data to check
*/
void CheckSortDown( const BufTypeVector& data )
{
    for( int nElem=1; nElem<NUM_ELEMENTS; ++nElem )
    {
        if( data[ nElem-1 ] < data[ nElem ] ) {
            assert( 0 );
        }
    }
}
